/*
Java source file
Copyright: Umschalt.com 2012
*/
package com.david.documentation.web.view.dataProvider;

import com.david.documentation.domain.entities.doku.Doku;
import com.david.documentation.service.search.SearchService;
import org.apache.wicket.extensions.markup.html.repeater.util.SortableDataProvider;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;

import java.util.Iterator;

public class SearchResultDataProvider extends SortableDataProvider {

	private SearchService searchService;
	private String searchString;

	public  SearchResultDataProvider(String searchString,SearchService searchService){
		this.searchString = searchString;
		this.searchService = searchService;
	}

	public Iterator iterator(int first, int count) {
		return searchService.findDokuNamesAndDescriptionSqlLimit(searchString,first,count).iterator();
	}

	public int size() {
		return searchService.findDokuNamesAndDescriptionSql(searchString).size();
	}

	public IModel model(Object object) {
		return Model.of((Doku) object);
	}
}
